package finger.dao.impl;

import finger.dao.OrderItemDao;
import finger.domain.OrderItem;

import java.util.List;

public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {

    @Override
    public void saveOrderItem(OrderItem orderItem) {
        String sql = "insert into t_order_item(`id`,`name`,`count`,`price`,`total_price`,order_id)values(" +
                "?,?,?,?,?,?)";
        update(sql, orderItem.getId(), orderItem.getName(), orderItem.getCount(), orderItem.getPrice(), orderItem.getTotalPrice(), orderItem.getOrderId());

    }

    @Override
    public List<OrderItem> queryItemDetailsByOrderId(String orderId) {
        String sql = "SELECT `id`,`name`,`count`,`price`,`total_price` totalPrice,`order_id` orderId FROM t_order_item WHERE order_id=?";
        return getQueryForList(OrderItem.class,sql,orderId);
    }
}
